local function autoCompleteFunc(command, args)
local returnVal = {}
	if !args[1] then
		for i = 1, #AMax.ConCommands do
			table.insert(returnVal, AMax.ConCommands[i]["C"]
		end
	elseif args[1] and not args[2] then
		for k,v in pairs(player.GetAll()) do
			table.insert(returnVal, v:Nick())
		end
	end	
		return returnVal
end

function AM_ConCommand(sender, command, arguments)
	for i = 1, #AMax.ConCommands do
		if arguments[1] then
			if string.lower( arguments[1] ) == string.lower( AMax.ConCommands[i]["C"] ) then
				table.remove(arguments, 1)
				AMax.ConCommands[i]["F"](sender, command, arguments)
			end
		end
	end
end
concommand.Add("AMax", AM_ConCommand, autoCompleteFunc)

function Slay(sender, command, args)
	PrintTable(args)
	if args[1] then
		local information = {}
		information.i = args[1]
		local ply = AMax:FindPlayer(information)
			ply:Kill()
	else
		AMax:Notify(sender, "More arguments are required!")
	end
end
AMax:AddConCommand("Slay", Slay, "Punishment", "Slay <Name/SteamID/IP Address> - Slays a player", 1)
AMax:AddChatCommand("Slay", "Slay")

function Ghost(sender, command, args)
	if args[1] then
		local information = {}
		information.i = args[1]
		local ply = AMax:FindPlayer(information)
			ply:SetColor(ply:GetColor() - Color(0,0,0,255)) // I've tried to preserve as much colour as I could.
	else
		AMax:Notify(sender, "More arguments are required!")
	end
end
AMax:AddConCommand("Ghost", Ghost, "Fun", "Ghost <Name/SteamID/IP Address> - Makes a player invisible", 1)
AMax:AddChatCommand("Ghost", "Ghost")

function UnGhost(sender, command, args)
	if args[1] then
		local information = {}
		information.i = args[1]
		local ply = AMax:FindPlayer(information)
			ply:SetColor(ply:GetColor() + Color(0,0,0,255)) // yet again, I've tried to preserve as much colour as I could.
	else
		AMax:Notify(sender, "More arguments are required!")
	end
end
AMax:AddConCommand("UnGhost", UnGhost, "Fun", "UnGhost <Name/SteamID/IP Address> - Makes a player visible", 1)
AMax:AddChatCommand("UnGhost", "UnGhost")

function UnlimitedAmmo(sender, command, args)
	if args[1] then
		local information = {}
		information.i = args[1]
		local ply = AMax:FindPlayer(information)
			ply.UnlimitedAmmo = true
	else
		AMax:Notify(sender, "More arguments are required!")
	end
end
AMax:AddConCommand("UnlimitedAmmo", UnlimitedAmmo, "Fun", "UnlimitedAmmo <Name/SteamID/IP Address> - Gives a player unlimited ammo", 1)
AMax:AddChatCommand("UnlimitedAmmo", "UnlimitedAmmo")

function LimitedAmmo(sender, command, args)
	if args[1] then
		local information = {}
		information.i = args[1]
		local ply = AMax:FindPlayer(information)
			ply.UnlimitedAmmo = false
	else
		AMax:Notify(sender, "More arguments are required!")
	end
end
AMax:AddConCommand("LimitedAmmo", LimitedAmmo, "Fun", "LimitedAmmo <Name/SteamID/IP Address> - Limits a players ammo", 1)
AMax:AddChatCommand("LimitedAmmo", "LimitedAmmo")

function Crush(sender, command, args)
	if args[1] then
		local information = {}
		information.i = args[1]
		local ply = AMax:FindPlayer(information)
			local ent = ents.Create("prop_physics")
			ent:SetModel("models/props_wasteland/cargo_container01b.mdl")
			ent:SetColor(Color(0,255,0,255))
			ent:SetMaterial("debug/white")
			local phys = ent:GetPhysicsObject()
			ent:SetPos(ply:GetPos() + Vector(0,0,256))
			ent:Spawn()
			phys:SetVelocity(Vector(0,0,1000))
	else
		AMax:Notify(sender, "More arguments are required!")
	end
end
AMax:AddConCommand("Smite", Crush, "Fun", "Crush <Name/SteamID/IP Address> - Smites a player", 1)
AMax:AddChatCommand("Smite", "Crush")

function Set(sender, command, args)
	AMax[args[1]] = args[2]
end
AMax:AddConCommand("Set", Set, "Administration", "Set <Key> <Value> - Sets a key/value for the config.txt", 2)